package com.xinfu.newproject.adapter.paycost_adapter;

import android.widget.CheckBox;
import android.widget.CompoundButton;

import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.BaseViewHolder;
import com.xinfu.newproject.R;
import com.xinfu.newproject.bean.paycost.bean.GetBillByTypeBean;


/**
 *
 */
public class PropertyFeeAdapter extends BaseQuickAdapter<GetBillByTypeBean.ResultBean, BaseViewHolder> {

    CheckBox checkBox;
    private PayCostCheckLisener payCostCheckLisener;

    public PropertyFeeAdapter(PayCostCheckLisener payCostCheckLisener) {
        super(R.layout.recycler_property_fee, null);
        this.payCostCheckLisener = payCostCheckLisener;
    }

    @Override
    protected void convert(BaseViewHolder helper, GetBillByTypeBean.ResultBean item) {
        helper.setText(R.id.recycler_property_fee_money, "¥" + item.getZjJe());
        helper.setText(R.id.recycler_property_fee_time, item.getZjCny());
        helper.setText(R.id.recycler_property_fee_type, "明细:  " + item.getFeeName());
        checkBox = helper.getView(R.id.recycler_property_fee_cb);
        checkBox.setChecked(item.isCheck());
        checkBox.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
            @Override
            public void onCheckedChanged(CompoundButton compoundButton, boolean b) {
                payCostCheckLisener.checkMoneyLisener(helper.getPosition(), b, item.getZjJe());
            }
        });
    }


    public interface PayCostCheckLisener {
        void checkMoneyLisener(int position, boolean isCheck, double money);
    }
}
